/***************************************************************************
 *	@file 		fetion_config.h
 *	@Author 	baoyu0125@gmail.com
 *	@create		2011-7
 *	@version 	1.0.0
 *	@brief		definition of class Config.
 *				class Config contain configuration of hole program and user
 *				top level functions
 *	@modify		none
 ***************************************************************************/

#ifndef FETION_CONFIG_H
#define FETION_CONFIG_H

class userlist;
class Config
{
public:
	friend class currentUser;
	friend class loginThreadCallable;
	// just only one object in whole program, construct at first time
	// get the instance by get_instance without parameter.
	static Config *get_instance(const std::string globalPath = "")
	{
		static Config config(globalPath);
		return &config;
	}

	~Config(); 
	int init(const std::string &userId);
	int create_table_in_db();
	int load_from_database();

	int generate_config_body(std::string &body);
	int parse_config_xml(Glib::ustring &xml);
	int save_to_database();

	int get_phrase(const int id, std::string &phrase);
	
	const std::string global_path;	// global config path
	userlist *user_list;

public:
	int 		autoLogin;	
	int 		sendButton;
	int 		autoReply;
	int 		savePasswd;
	int 		autoDisplayMsg;
	int			onlineNotify;
	int			sysNotify;

private:
	Config(const std::string &globalPath);

	std::string userPath;
	std::string db_path;

	std::string autoReplayMsg;
	
	std::string configServersVersion;
	std::string configParametersVersion;
	std::string configHintsVersion;
	
	std::string portraitServerName;
	std::string portraitServerPath;
	
	std::string sipcProxyIP;
	unsigned int sipcProxyPort;
};

#endif
